package com.iMusic.presentationLayer;

import java.io.IOException;
import java.sql.SQLException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.iMusic.businessLogicLayer.Account;
import com.iMusic.businessLogicLayer.Cart;
import com.iMusic.businessLogicLayer.CustomerReport;
import com.iMusic.businessLogicLayer.Staff;
import com.iMusic.util.UserMessages;

public class GenerateCustomerReport extends HttpServlet{

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String redirection = "adminFS.jsp?action=CustomerReporting";
		HttpSession session = request.getSession();

		String startDate = request.getParameter("StartDate");
		String endDate = request.getParameter("EndDate");
		
		CustomerReport custReport = new CustomerReport(startDate, endDate);
		
		try {
			custReport.generateProductsPerCustomer();
			custReport.generateVIPConsumptions();
			custReport.generateBestSaleProducts();
			custReport.generateFeedbacks();
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		session.setAttribute("CustomerReport", custReport);

		response.sendRedirect(redirection);
		
	}
	
}
